var e = require("../../../@babel/runtime/helpers/interopRequireDefault").default,
  t = require("../../../@babel/runtime/helpers/objectSpread2"),
  r = require("../../../components/base/m-form/core"),
  s = new(e(require("../../../utils/multimedia/index")).default)({
    appId: 120,
    business: "YPJX",
    reqsource: "YPJX",
    packagename: "wx2e0c4fafe2aa2e36"
  });
Component((0, r.formItem)()({
  externalClasses: ["custom-class", "upload-class"],
  properties: {
    count: {
      type: "number",
      value: 9
    },
    entryId: {
      type: "number"
    }
  },
  data: {},
  lifetimes: {},
  methods: {
    chooseImage: function () {
      var e = this;
      wx.chooseMedia({
        count: this.data.count,
        mediaType:['image'],
        fail(error){
          console.log(error)
        },
        success: function (t) {
          console.log(t)
          var r = t.tempFiles.map((function (e) {
            return {
              url: e.tempFilePath,
              progress: 0,
              status: "pedding",
              
              id: (65536 * (1 + Math.random()) | 0).toString(16).substring(1)
            }
          }));
          e.triggerEvent("tempFilechange", r), e.uploadFile(r)
        }
      })
    },
    reUpload: function (e) {
      e.progress = 0, e.status = "pedding", this.triggerEvent("tempFilechange", [e]), this.uploadFile([e])
    },
    uploadFile: function (e) {
      var r = this;
      s.upload({
        entryId: this.data.entryId,
        tempFilePaths: e,
        success: function (e) {
          var s, a = t(t({}, e.item), {}, {
            url: e.url,
            deliverUrl: e.deliverUrl,
            fileId: e.fileId,
            status: "fulfilled",
            progress: 100
          });
          r.triggerEvent("onSuccess", a), null === (s = r.onChange) || void 0 === s || s.call(r, a)
        },
        fail: function (e) {
          r.triggerEvent("onFail", t(t({}, e.item), {}, {
            status: "rejected"
          }))
        },
        onProgressUpdate: function (e) {
          var s = 100 === e.progress ? 80 : e.progress;
          r.triggerEvent("onProgressUpdate", t(t({}, e.item), {}, {
            progress: s
          }))
        }
      })
    }
  }
}));